import { useEffect, useRef, useCallback } from 'react'
import deepSet from '../function/deepSet'

// useRef 的封装：消除current的引用
const useCurrent = (obj) => {
    const _ref = useRef(obj)
    const setRef = useCallback((_) => {
        if (!Object.keys(_).length) return
        Object.assign(_ref.current, _)
    }, [])
    return [_ref.current, setRef]
}

export default useCurrent